package com.ryan.ohos.extension.widget.expandablelist;

public abstract class BaseExpandableItemProvider implements ExpandableItemProvider,
        TypeExpandableListContainer {

    private final DataSetObservable mDataSetObservable = new DataSetObservable();

    /**
     * addDataSetObserver
     *
     * @param observer observer
     */
    public void addDataSetObserver(DataSetObserver observer) {
        mDataSetObservable.addObserver(observer);
    }

    /**
     * removeDataSetObserver
     *
     * @param observer observer
     */
    public void removeDataSetObserver(DataSetObserver observer) {
        mDataSetObservable.removeObserver(observer);
    }

    /**
     * notifyDataSetInvalidated
     */
    public void notifyDataSetInvalidated() {
        mDataSetObservable.notifyInvalidated();
    }

    /**
     * notifyDataSetChanged
     */
    public void notifyDataSetChanged() {
        mDataSetObservable.notifyChanged();
    }

    /**
     * areAllItemsEnabled
     *
     * @return boolean
     */
    public boolean areAllItemsEnabled() {
        return true;
    }

    /**
     * onGroupCollapsed
     *
     * @param groupPosition groupPosition
     */
    public void onGroupCollapsed(int groupPosition) {
    }

    /**
     * onGroupExpanded
     *
     * @param groupPosition groupPosition
     */
    public void onGroupExpanded(int groupPosition) {
    }

    /**
     * getCombinedChildId
     *
     * @param groupId groupId
     * @param childId childId
     * @return long
     */
    public long getCombinedChildId(long groupId, long childId) {
        return 0x8000000000000000L | ((groupId & 0x7FFFFFFF) << 32) | (childId & 0xFFFFFFFF);
    }

    /**
     * getCombinedGroupId
     *
     * @param groupId groupId
     * @return long
     */
    public long getCombinedGroupId(long groupId) {
        return (groupId & 0x7FFFFFFF) << 32;
    }

    /**
     * isEmpty
     *
     * @return boolean
     */
    public boolean isEmpty() {
        return getGroupCount() == 0;
    }


    /**
     * getChildType
     *
     * @param groupPosition groupPosition
     * @param childPosition childPosition
     * @return int
     */
    public int getChildType(int groupPosition, int childPosition) {
        return 0;
    }

    /**
     * getChildTypeCount
     *
     * @return int
     */
    public int getChildTypeCount() {
        return 1;
    }

    /**
     * getGroupType
     *
     * @param groupPosition groupPosition
     * @return int
     */
    public int getGroupType(int groupPosition) {
        return 0;
    }

    /**
     * getGroupTypeCount
     *
     * @return int
     */
    public int getGroupTypeCount() {
        return 1;
    }
}
